package com.yuqiao.read.design.templatefun;

public class Duck implements Comparable {
    private String name;
    private double weight;

    public Duck(String name,double weight){
        this.name = name;
        this.weight = weight;
    }

    @Override
    public String toString() {
        return "Duck{" +
                "name='" + name + '\'' +
                ", weight=" + weight +
                '}';
    }

    @Override
    public int compareTo(Object o) {
        Duck otherDuck = (Duck) o;
        if(this.weight<otherDuck.weight){
            return  -1;
        }else if(this.weight == otherDuck.weight){
            return 0;
        }else {
            return 1;
        }
    }
}
